package SortMethod;

import SortHelper.SortHelper;

//先实现插入排序的优化版
public class InsertSortPlus {

    private InsertSortPlus(){}

    public static <E extends Comparable<E>> void sort(E[] arr){
        //不交换版的插入排序
        for (int i = 1; i < arr.length; i++) {
            E temp = arr[i];
            int j = i;
            for (; j > 0; j--) {
                if (temp.compareTo(arr[j - 1]) < 0){
                    arr[j] = arr[j - 1];
                } else {
                    break;
                }
            }
            arr[j] = temp;
        }
    }
}
